<template>
    <view class="uam-head">
        <view class="uam-head-icon">
            <text @tap="handleToBack" class="iconfont icon-back hover-effect"></text>
            <text @tap="handleToHome" class="iconfont icon-shouye hover-effect"></text>
        </view>
        <!-- 中间标题区域 -->
        <view class="title-container">
            <image class="heading" src="/static/xiaoxiong.png"></image>
            <view class="uam-head-text">{{title}}</view>
        </view>
        <!-- 搜索图标容器（暂时注释掉） -->
        <!-- <view class="uam-head-search" @tap="toSearch">
            <text class="iconfont icon-sousuo hover-effect"></text>
        </view> -->
    </view>
</template>

<script>
export default {
    name: "UAMHeader",
    props: ['title'],
    methods: {
        handleToBack() {
            const pages = getCurrentPages();
            if (pages.length > 1) {
                uni.navigateBack();
            } else {
                uni.switchTab({
                    url: '/pages/index/index'
                });
            }
        },
        handleToHome() {
            uni.switchTab({
                url: '/pages/index/index'
            });
        },
		toSearch(){
			uni.navigateTo({
				url:'/pages/search/search'
			})
		}
		
    }
}
</script>

<style>
.uam-head {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20rpx;
    background: linear-gradient(to right, #333, #222);
    box-shadow: 0 4rpx 10rpx rgba(0, 0, 0, 0.3);
    position: relative;
    height: 100rpx;
    box-sizing: border-box;
}

.uam-head-icon {
    position: absolute;
    left: 20rpx;
    display: flex;
    gap: 20rpx;
}

.uam-head-icon .iconfont {
    font-size: 40rpx;
    color: #ffffff;
    transition: color 0.3s ease;
}

/* 搜索图标容器样式 */
.uam-head-search {
    position: absolute;
    right: 20rpx;
    font-size: 40rpx;
    color: #ffffff;
    transition: color 0.3s ease;
}

.hover-effect:hover {
    color: #007aff;
}

.title-container {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 65%;
    max-width: 60%;
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 25rpx;
    padding: 0 20rpx;
    border: 1rpx solid rgba(255, 255, 255, 0.1);
}

.heading {
    width: 60rpx;
    height: 60rpx;
    border-radius: 50%;
    object-fit: cover;
    border: 2rpx solid rgba(255, 255, 255, 0.5);
}

.uam-head-text {
    font-size: 30rpx;
    font-weight: bold;
    color: rgba(255, 255, 255, 0.9);
    margin-left: 15rpx;
    max-width: 240rpx;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 0 1rpx 2rpx rgba(0, 0, 0, 0.2);
}
</style>    